<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition> 
        <p:toolbar>  
            <p:toolbarGroup style="text-align: center">  
                <p:outputLabel value="Tu Carrito" style="font-size: 16px;text-align: center"></p:outputLabel>
            </p:toolbarGroup> 
        </p:toolbar>
        <p:panelGrid columns="1" >
            <p:spacer width="180" height="30" />
            <h:outputLabel style="font-weight: bold" value="Este es el resumen de su compra, todo los envios se realizan en 24h siempre que exista stock. Para los pedidos que contengan algun producto en espera de reposición el tiempo máximo estimado de entrega será de 72h. Como ya sabe Retailshop no cobra los gastos de envío. Gracias por confiar en Retailshop"/>
            <p:panelGrid columns="3" style="alignment-adjust: central">
                <p:outputLabel style="text-align: right;font-size: 20px;font-weight: bold" value="Total: #{purchaseManagedBean.total()} €"/>
                <c:if test="#{purchaseManagedBean.canPurchased()}">
                <p:graphicImage value="recursos/images/za_purchase.png" height="50px"  />
                <h:form>
                    <p:commandLink id="selectButton"  ajax="false" oncomplete="carDialog.show()" action="#{purchaseManagedBean.doShopping}">
                        <p:graphicImage value="recursos/images/za_compra.png" height="90px"  />
                    </p:commandLink>
                </h:form>
                </c:if>

            </p:panelGrid>
        </p:panelGrid>
        <h:form id="form">  


            <p:growl id="msgs" showDetail="true" />  

            <p:dataTable id="items" var="itemPurchased" value="#{purchaseManagedBean.cart}" emptyMessage="Tu carrito aún está vacío">  

                <p:column headerText="Ref" style="width:24%;text-align: center">  
                    <h:outputText value="#{itemPurchased.item.idItem}" />  
                </p:column>  

                <p:column headerText="Nombre" style="width:24%;text-align: center">  
                    <h:outputText value="#{itemPurchased.item.name}" />  
                </p:column>  

                <p:column headerText="Estado" style="width:24%;text-align: center">  
                    <h:outputText value="En stock" style="font-size: 13px; color: green;font-weight:bold;" rendered="#{itemPurchased.item.stock()}"/>
                    <h:outputText value="Reposición de 24 a 72h" style="font-size: 13px; color: red;font-weight:bold;" rendered="#{itemPurchased.item.reposicion()}"/>
                </p:column> 

                <p:column headerText="Precio" style="width:24%;text-align: center">  
                    <h:outputText value="#{itemPurchased.price} €" />  
                </p:column>  

                <p:column headerText="Cantidad" style="width:24%;text-align: center">  
                    <h:outputText value="#{itemPurchased.quantity}" />  
                </p:column> 

                <p:column headerText="Resumen" style="width:24%;text-align: center">  
                    <h:outputText value="#{itemPurchased.resumen()} €" />  
                </p:column>  

                <p:column headerText="Eliminar" style="width:4%;text-align: center">  
                    <p:commandLink  update="items"
                                    actionListener="#{purchaseManagedBean.deleteCart(itemPurchased)}" >
                        <p:graphicImage value="recursos/images/za_delete.png" height="50px"  />
                    </p:commandLink> 
                </p:column>  

            </p:dataTable>  

            <p:dialog header="Car Detail" widgetVar="carDialog" resizable="false" id="carDlg"  
                      showEffect="fade" hideEffect="explode" modal="true" >  

                <h:panelGrid id="display" columns="1" style="margin:0 auto;">  

                    <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
                        <input type="hidden" name="cmd" value="_s-xclick"/>
                        <input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHXwYJKoZIhvcNAQcEoIIHUDCCB0wCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYBt1FE7wjQ8p/gOP+TyuyCSP1pzR3fWNTuhQj1N+0M+/sfiEciM65fEC2OPkY1eREz+0DZcYOcvKZcXvVky13v+5LHfXQdhEywWKR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z4s6w==-----END PKCS7-----
                               "/>
                        <input type="image" src="https://www.paypalobjects.com/es_ES/ES/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal. La forma rápida y segura de pagar en Internet."/>
                        <img alt="" border="0" src="https://www.paypalobjects.com/es_ES/i/scr/pixel.gif" width="1" height="1"/>
                    </form>

                </h:panelGrid>  

            </p:dialog>  

        </h:form>  

    </ui:composition>
</html>
